package com.caih.contacts.dao;
import com.caih.contacts.entity.*;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;


public interface EmployeesDao extends JpaRepository<Employees,Integer> {
    @Query(value = "select e from Employees e where  e.name = ?1")
    public Employees findByName(@Param("name") String name);

    @Query(value = "select e from Employees e where  e.mobile = ?1")
    public Employees findByMobile(@Param("mobile") String mobile);

    @Query(value = "select e from Employees e where e.userid = ?1")
    public Employees findByUserId(@Param("id") String id);

    @Modifying
    @Query(value = "delete from Employees e where e.userid = ?1")
    public void deleteByUserId(String userid);

    @Query(value = "SELECT * FROM employees_info WHERE FIND_IN_SET(?1,department)",nativeQuery = true)
    public List<Employees> queryAllByDepartment(Integer department);



}
